package ca.uguu.unknown_space.worldobjects.background;

import java.util.AbstractMap;
import java.util.HashMap;

import ca.uguu.gamelib.libgdx.structures.BoundedFloat;
import ca.uguu.gamelib.libgdx.structures.BoundedInt;

public abstract class VesselDef {
	final public String vesselType;
	final public BoundedFloat shieldStrength;
	final public BoundedFloat hullIntegrity;
	final public BoundedFloat sensorsIntegrity;
	final public BoundedFloat shieldsIntegrity;
	final public BoundedFloat powerIntegrity;
	final public BoundedInt crew;
	
	//Vessels take an instance of this and load the appropriate definitions to complete the model
	//They also take a separate captain definition (reassignable while the ship exists)
	
	//Weapon definitions are a sub-object of this thing
	//So are mods
	public VesselDef(String vesselType){
		this.vesselType = vesselType;
		this.shieldStrength = new BoundedFloat();
		this.hullIntegrity = new BoundedFloat();
		this.shieldsIntegrity = new BoundedFloat();
		this.sensorsIntegrity = new BoundedFloat();
		this.powerIntegrity = new BoundedFloat();
		this.crew = new BoundedInt();
	}
	public VesselDef(AbstractMap<String, Object> definition){
		this.vesselType = (String)definition.get("type");
		this.shieldStrength = new BoundedFloat((Float)definition.get("shieldStrength"));
		this.hullIntegrity = new BoundedFloat((Float)definition.get("hullIntegrity"));
		this.shieldsIntegrity = new BoundedFloat((Float)definition.get("shieldsIntegrity"));
		this.sensorsIntegrity = new BoundedFloat((Float)definition.get("sensorsIntegrity"));
		this.powerIntegrity = new BoundedFloat((Float)definition.get("powerIntegrity"));
		this.crew = new BoundedInt((Integer)definition.get("crew"));
	}
	
	public AbstractMap<String, Object> serialise(){
		AbstractMap<String, Object> content = new HashMap<String, Object>();
		content.put("shieldStrength", this.shieldStrength.get());
		content.put("hullIntegrity", this.hullIntegrity.get());
		content.put("shieldsIntegrity", this.shieldsIntegrity.get());
		content.put("sensorsIntegrity", this.sensorsIntegrity.get());
		content.put("powerIntegrity", this.powerIntegrity.get());
		content.put("crew", this.crew.get());
		return content;
	}
}
